import java.util.Scanner;

public class __1 {
	public static void main(String[] args) {
		String dd = "y";// 判断Y/N
		String c = "";// 用户名
		String d = "";// 密码
		int x = 0;// 随机会员卡号
		String cc = "";// 登陆用户名
		String ddd = ""; // 登陆密码
		boolean k = true;// 输入密码三次错误退出程序
		while (!dd.equals("n")) {
			System.out.println("**********欢迎进入富翁抽奖系统***********");
			System.out.println("\t\t1.注册\n\t\t2.登陆\n\t\t3.抽奖");
			System.out.println("**********************************");
			System.out.print("请选择菜单：");
			Scanner n = new Scanner(System.in);
			int b = n.nextInt();
			switch (b) {
			case 1:
				System.out.println("注册>>>>>>>\n请输入注册信息");
				System.out.print("用户名：");
				c = n.next();
				System.out.print("密码");
				d = n.next();
				x = (int) (Math.random() * 9000)+1000;
				System.out.println("\n注册成功请记住你的密码和账号");
				System.out.println("用户名\t密码\t会员号");
				System.out.println(c + "\t" + d + "\t" + x);
				break;
			case 2:
				if (c == "" && d == "") {
					System.out.println("请先注册");
				} else {
					System.out.println("登陆>>>>>>>");
					for (int h = 3; h > 0; h--) {
						System.out.print("请输入用户名");
						cc = n.next();
						System.out.print("请输入密码");
						ddd = n.next();
						if (cc.equals(c) && ddd.equals(d)) {
							System.out.println("\n欢迎你" + c + "\n");
							break;
						} else {
							System.out.println("密码错误还有" + (h) + "机会");
							if (h == 1) {
								System.out.println("密码或账号错误多次 退出程序");
								k = false;
							}
						}
					}
				}
				break;
			case 3:
				if (cc == "" && ddd == "") {
					System.out.println("请先登陆");
				} else {
					System.out.println("抽奖>>>>>>>>");
					System.out.print("请输入会员卡号");
					int g = n.nextInt();
					if (g < 999 || g > 9999) {
						System.out.println("不是有效会员，请重输入");
					} else {
						int xx = (int) (Math.random() * 9000)+1000;
						int xxx = (int) (Math.random() * 9000)+1000;
						int xxxx = (int) (Math.random() * 9000)+1000;
						int xxxxx = (int) (Math.random() * 9000)+1000;
						if (g == xx && g == xxx && g == xxxx && g == xxxxx) {
							System.out.println("是幸运");
						} else {
							System.out.println("不是");
						}
						System.out.println("今日的会员卡号是" + xx + "\t" + xxx + "\t" + xxxx + "\t" + xxxx);
					}
				}
				break;
			default:
				System.out.println("输入的数字不对 请重输入！！！");
			}
			if (k == false) {
				break;
			}
			System.out.println("要继续吗？（y/n）");
			dd = n.next();
		}
		System.out.println("退出");
	}
}
